package com.storeapp.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.storeapp.dao.ProductDao;
import com.storeapp.entity.domain.Product;

@Component
@Transactional
public class ProductService {
	@Autowired
	private ProductDao productDao;
	
	@Transactional(readOnly = true)
	public Product getProduct(Long id) {
		return productDao.get(id);
	}

	public void saveOrUpdateProduct(Product entity) {
		productDao.save(entity);
	}
	
	public void deleteProduct(Product entity) {
		productDao.delete(entity);
	}

	public List<Product> listAll() {
		return productDao.getAll();
	}
}
